#ifndef MOISTUREMETERWATCHER_H
#define MOISTUREMETERWATCHER_H

#include <QWidget>
#include "GPAbstractMoistureMeter.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MoistureMeterWatcher; }
QT_END_NAMESPACE

/**
 * @brief 水分仪界面
 *
 * 应用示意：
 * @example
 * @code
 *#include "MoistureMeterWatcher.h"
 *#include <QApplication>
 *#include "MoistureMeterLDS_1G.h"
 *int main(int argc, char *argv[])
 *{
 *    QApplication a(argc, argv);
 *    MoistureMeterWatcher w;
 *    MoistureMeterLDS_1G* d = new MoistureMeterLDS_1G(&w);
 *    if(d->openSeriesPort("COM2"
 *                      ,QSerialPort::Baud9600
 *                      ,QSerialPort::NoParity
 *                      ,QSerialPort::Data8
 *                      ,QSerialPort::OneStop))
 *    {
 *        w.setupMoistureMeter(d);
 *    }
 *    w.show();
 *    return a.exec();
 *}
 * @endcode
 */
class MoistureMeterWatcher : public QWidget
{
    Q_OBJECT

public:
    MoistureMeterWatcher(QWidget *parent = nullptr);
    ~MoistureMeterWatcher();
    //设置水分仪
    void setupMoistureMeter(GPAbstractMoistureMeter *moisMeter);
private slots:
    void onValueChange(int index
                     ,short sample
                     ,double temperature
                     ,double weight
                     ,double waterRatio
                     ,double voltage
                     ,int measureTimes);
private:
    Ui::MoistureMeterWatcher *ui;
    GPAbstractMoistureMeter* m_moisMeter;
};
#endif // MOISTUREMETERWATCHER_H
